﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;
using System.Xml;
using System.Text;

namespace Billder.BL
{
    public class Part
    {
        public int ID;
        public string Name;
        public int Qty;
        public Part() : this(0, "", 0) { }
        public Part(int ID, string Name, int Qty)
        {
            this.ID = ID;
            this.Name = Name;
            this.Qty = Qty;
        }
        public Part( string XML ) {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(XML);

            XmlNode parts = doc.SelectSingleNode("/*");
            this.ID = int.Parse(parts.Attributes["id"].Value);
            this.Qty = int.Parse(parts.Attributes["qty"].Value);
        }
        public string asJS() {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("new Part({0} , '{1}' , {2})",this.ID , this.Name , this.Qty); 
            return sb.ToString();
        }
    }
}